package src.hash;

public class no242 {
//有效的字母异位词
    public static void main(String[] args) {
        boolean res = isAnagram("abcc", "acbca");
        System.out.println(res);
    }

    public static boolean isAnagram(String s, String t) {
        int[] count = new int[26];
        for (int i = 0; i < s.length(); i++) {
            count[s.charAt(i) - 'a']++;   //charAt方法获取字符串指定索引i位置的字符
        }
        for (int i = 0; i < t.length(); i++) {
            count[t.charAt(i) - 'a']--;
        }
        for (int i = 0; i < 26; i++) {
            if (count[i] != 0) {
                return false;
            }
        }
        return true;

    }
}
